[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
case                     Signals the Start of a CASE Statement


 case <expr> of
   <clist> : <statement>;
   <clist> : <statement>;
   ...
   <clist> : <statement>
   else      <statement>
 end;

    A CASE statement executes one of a list of statements based on the
    value of an ordinal (Integer, Char, Boolean, enumerated) expression.
    The value is compared against one or more lists of values. If the
    value is found in a list, the corresponding statement is executed and
    the program then continues execution with the first statement
    following the END of the case statement. If no match is made, then the
    ELSE statement is executed If no ELSE statement is present, then none
    of the statements is executed.

          <expr>    An ordinal expression: any legal combination of
                    constants, variables, function calls, and operators,
                    yielding an ordinal (Integer, Char, Boolean,
                    enumerated) value.

         <clist>    A list of ordinal values, separated by commas  Must be
                    of the same type as <expr>. Turbo Pascal allows the
                    use of subranges (<low>..<high>) in the place of any
                    value.

     <statement>    Any legal statement. For multiple statements, use a
                    compound statement (see BEGIN).

  -------------------------------- Example ---------------------------------

           case Score of
             90..100 : Grade := 'A';
             80..89  : Grade := 'B';
             70..79  : Grade := 'C';
             60..69  : Grade := 'D';
             else      Grade := 'F'
           end;

See Also: begin else
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson